@extends('Admin.layout.layout')
@section('title')
<title>后台管理系统-商品详情表</title>
@endsection
@section('con')
<div class="row">
    <div class="col-lg-12">
        <h1 class="page-header" style="color:blue">商品列表</h1>
    </div>
    <!-- /.col-lg-12 -->
</div>
<!-- /.row -->
<div class="row"> 
   <div class="col-lg-12"> 
    <div class="panel panel-default"> 
     <div class="panel-heading" >
     商品详情表
     </div> 
     <!-- /.panel-heading --> 
     <div class="panel-body"> 
      <div class="dataTable_wrapper"> 
       <div id="dataTables-example_wrapper" class="dataTables_wrapper form-inline dt-bootstrap no-footer">
      <form action="{{url('/admin/goods/index')}}" method="get">
        <div class="row">
         <div class="col-sm-6">
          <div class="dataTables_length" id="dataTables-example_length">
           <label>显示 
            <select name="num" aria-controls="dataTables-example" class="form-control input-sm">
              <option value="10" @if(!empty($data['num']) && $data['num'] == 10) selected @endif>10</option>
              <option value="25" @if(!empty($data['num']) && $data['num'] == 25) selected @endif>25</option>
              <option value="50" @if(!empty($data['num']) && $data['num'] == 50) selected @endif>50</option>
              <option value="100" @if(!empty($data['num']) && $data['num'] == 100) selected @endif>100</option>
            </select> 条</label>
          </div>
         </div>
         <div class="col-sm-6">
          <div id="dataTables-example_filter" class="dataTables_filter">
           <label>查询:<input type="search" name="keywords" value="{{ $data['keywords'] or '' }}" class="form-control input-sm" placeholder="" aria-controls="dataTables-example" /></label>
            <button class="btn">搜索</button>
          </div>
         </div>
        </div>
      </form>
        <div class="row">
         <div class="col-sm-12">
          <table id="dataTables-example" class="table table-striped table-bordered table-hover dataTable no-footer" role="grid" aria-describedby="dataTables-example_info"> 
           <thead> 
            <tr role="row">
             <th class="sorting_asc" tabindex="0" aria-controls="dataTables-example" rowspan="1" colspan="1" style="width: 100px;" aria-sort="ascending" aria-label="Rendering engine: activate to sort column descending">商品名称</th>
             <th class="sorting" tabindex="0" aria-controls="dataTables-example" rowspan="1" colspan="1" style="width: 100px;" aria-label="Browser: activate to sort column ascending">商品类型</th>
             <th class="sorting" tabindex="0" aria-controls="dataTables-example" rowspan="1" colspan="1" style="width: 100px;" aria-label="Platform(s): activate to sort column ascending">商品品牌</th>
             <th class="sorting" tabindex="0" aria-controls="dataTables-example" rowspan="1" colspan="1" style="width: 126px;" aria-label="Engine version: activate to sort column ascending">所属店铺</th>
             <th class="sorting" tabindex="0" aria-controls="dataTables-example" rowspan="1" colspan="1" style="width: 126px;" aria-label="Engine version: activate to sort column ascending"> 价格</th>
             <th class="sorting" tabindex="0" aria-controls="dataTables-example" rowspan="1" colspan="1" style="width: 126px;" aria-label="Engine version: activate to sort column ascending">库存量</th>
             <th class="sorting" tabindex="0" aria-controls="dataTables-example" rowspan="1" colspan="1" style="width: 100px;" aria-label="CSS grade: activate to sort column ascending">操作</th>
            </tr> 
           </thead> 
           <tbody> 
              @foreach($goods as $k=>$v)
                <tr class="gradeA odd" role="row"> 

                 <td class="sorting_1">{{$v->sname}}</td> 
                 <td>{{$v->tname}}</td> 
                 <td>{{$v->brand}}</td> 
                 <td class="center">{{$v->dname}}</td> 
                  <td class="center">{{$v->price}}</td> 
                     <td class="center">{{$v->num}}</td> 
                 <td class="center">
                   <a class="btn btn-danger btn-xs btn-delete"  name="{{$v->id}}">删除</a>
                    
                    <a href="{{url('/admin/goods/edit',['id'=>$v->id])}}" class="btn btn-success btn-xs" >详情</a></td> 
                    
                </tr>
               @endforeach
           </tbody> 
          </table>
         </div>
        </div>
        <div class="row">
         <div class="col-sm-12">
          <div class="dataTables_paginate paging_simple_numbers" id="dataTables-example_paginate">
            {!! $goods->appends($data)->render() !!}
          </div>
         </div>
        </div>
       </div> 
      </div> 
      <div class="row">
      <div class="col-sm-6">
      <div class="dataTables_info" id="dataTables-example_info" role="status" aria-live="polite">Showing 1 to 10 of 57 entries
      </div>
      </div>
      <div class="col-sm-6">
      <div class="dataTables_paginate paging_simple_numbers" id="dataTables-example_paginate">
      <ul class="pagination">
      <li class="paginate_button previous disabled" aria-controls="dataTables-example" tabindex="0" id="dataTables-example_previous">
      <a href="#">Previous</a>
      </li>
      <li class="paginate_button active" aria-controls="dataTables-example" tabindex="0">
      <a href="#">1</a>
      </li>
      <li class="paginate_button " aria-controls="dataTables-example" tabindex="0">
      <a href="#">2</a>
      </li>
      <li class="paginate_button " aria-controls="dataTables-example" tabindex="0">
      <a href="#">3</a>
      </li>
      <li class="paginate_button " aria-controls="dataTables-example" tabindex="0">
      <a href="#">4</a>
      </li>
      <li class="paginate_button " aria-controls="dataTables-example" tabindex="0">
      <a href="#">5</a>
      </li>
      <li class="paginate_button " aria-controls="dataTables-example" tabindex="0">
      <a href="#">6</a>
      </li>
      <li class="paginate_button next" aria-controls="dataTables-example" tabindex="0" id="dataTables-example_next">
      <a href="#">Next</a>
      </li>
      </ul>
      </div>
      </div>
      </div>
      <!-- /.table-responsive --> 
      <div class="well"> 
       <h4>DataTables Usage Information</h4> 
       <p style="color:green">猪猪独家制作，版权归个人所有 详情请联系 <a href="https://datatables.net/" target="_blank">https://datatables.net/</a>.</p> 
       <a href="https://datatables.net/" target="_blank" class="btn btn-default btn-lg btn-block">View DataTables Documentation</a> 
      </div> 
     </div> 
     <!-- /.panel-body --> 
    </div> 
    <!-- /.panel --> 
   </div> 
   <!-- /.col-lg-12 --> 
  </div>

 
@endsection

@section('js')

<script type="text/javascript">

    $.ajaxSetup({
            headers: {
                'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
            }
    });

    $('.btn-delete').click(function(){
      
      var id =$(this).attr('name') ;
      var btn = $(this);
     

      $.post('/admin/goods/del',{id:id},function(data){
            //alert(data);
            if(data == 1){
               btn.parents('tr').remove();
            }else{
                alert('删除失败');
            }
      });
    })
  
</script>
@endsection
